package org.dgm.dgmJar.verifyCode;

import java.awt.image.BufferedImage;

/**
 * hg的验证码可作为例子
 * DCommVerifyCode 
 *  
 * @author：邓国明
 * @Oct 4, 2012 2:47:05 PM 
 * @version 1.0
 */
public class DCommVerifyCode {

	// public static String verifyCode = "verifyCode";
	// public static String outPutStream = "outPutStream";

	public String verifyCode;

	public BufferedImage image;

	public String getVerifyCode() {
		return verifyCode;
	}

	public BufferedImage getImage() {
		return image;
	}
	
	public DCommVerifyCode(){
		getverifyCodeAndStream();
	}

	/**
	 * 
	 * getverifyCodeAndStream
	 * 
	 * @return Map<String,Object>
	 * @Exception
	 * @author：邓国明
	 * @Aug 24, 2012 11:29:54 AM
	 * @update:
	 * @Aug 24, 2012 11:29:54 AM
	 */
	public void getverifyCodeAndStream() {


		try {
			SecurityCodeCreater scCreater = new SecurityCodeCreater();

			// FileOutputStream fos = new FileOutputStream("d:/test.jpg");
// JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(fos);

			this.verifyCode = scCreater.getRandString();
			//System.out.println(verifyCode);
			this.image = scCreater.getImage(verifyCode);
// encoder.encode(image);
		}
			catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
